package com.zhulin.comassistant;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

/**
 * @author ZL @朱林</a>
 * @Version 1.0
 * @Description TODO
 * @date 2021/08/09  16:50
 */
public class ZViewUtil {
    public static void setTextViewText(TextView textView, String text) {
        if (TextUtils.isEmpty(text) || null == textView) {
            return;
        }
        textView.post(() -> textView.setText(text));
    }

    public static String getTextViewText(TextView textView) {
        if (null == textView || null == textView.getText() || textView.getText().length() < 1) {
            return null;
        }
        return textView.getText().toString();
    }

    public static void viewRunUi(View view, Runnable runnable) {
        if (null != view && null != runnable) {
            view.post(runnable);
        }
    }

    public static void viewRunUi(View view, Runnable runnable, long delayMillis) {
        if (null != view && null != runnable) {
            view.postDelayed(runnable, delayMillis);
        }
    }
}